package core.objects;

import java.sql.Timestamp;
import java.util.Date;

public class BookComment extends AbstractComment {

    private int bookId;

    public BookComment(int id) {
        super(id);
    }

    public BookComment(int id, int bookId, int commenterId, String comment, int rating) {
        super(id);
        setBookCommentProperties(bookId, commenterId, comment, rating);
        this.timestamp = new Timestamp(new Date().getTime());
    }

    public BookComment(int id, int bookId, int commenterId, String comment, int rating, Timestamp timestamp) {
        super(id);
        setBookCommentProperties(bookId, commenterId, comment, rating);
        this.timestamp = timestamp;
    }

    private void setBookCommentProperties(int bookId, int commenterId, String comment, int rating) {
        this.bookId = bookId;
        this.commenterId = commenterId;
        this.comment = comment;
        this.rating = rating;
    }

    public int getBookId() {
        return bookId;
    }

    public void setBook(int bookId) {
        this.bookId = bookId;
    }

    @Override
    public Object[] toObjectArray() {
        return new Object[]{getBookId(), getCommenterId(), getComment(),getRating(), getTimestamp()};
    }
}
